﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;

namespace AnyOffice.general.work_plan.type
{
    public partial class edit : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int typeId = (Request.QueryString["type_id"] == null) ? 0 : int.Parse(Request.QueryString["type_id"].ToString());
                this.ViewState["TypeId"] = typeId;
                DataTable table = new PlanTypeDao().SelectByTypeId(base.Conn, typeId);
                if (table.Rows.Count == 0)
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = base.ShowPrompt("无相关计划类型", "index.aspx");
                    return;
                }
                this.txtTypeNo.Text = table.Rows[0]["TypeNo"].ToString();
                this.txtTypeName.Text = table.Rows[0]["TypeName"].ToString();
            }
            if (this.Page.IsPostBack)
            {
                PlanTypeDao dao2 = new PlanTypeDao();
                PlanTypeData data = new PlanTypeData();
                data.TypeId = Convert.ToInt32(this.ViewState["TypeId"]);
                data.TypeNo = Convert.ToInt32(this.txtTypeNo.Text);
                data.TypeName = this.txtTypeName.Text;
                dao2.Update(base.Conn, data);
                base.CloseConn();
                Response.Redirect("index.aspx");
            }
        } 

    }
}
